package
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import fl.controls.RadioButtonGroup;
	
	public class ExamThree extends MovieClip
	{
		private var radioG:RadioButtonGroup;
		public function ExamThree()
		{
			addEventFrame1();
			trace(11111111111111111);
		}
		
		private function addEventFrame1():void
		{
			radioG = new RadioButtonGroup("RadioButtonGroup");
			radioG.addRadioButton(r1);
			radioG.addRadioButton(r2);
			radioG.addRadioButton(r3);
			
			chaxun.addEventListener(MouseEvent.CLICK, onChaXun);
			weiyue.addEventListener(MouseEvent.CLICK, onWeiYue);
			luru.addEventListener(MouseEvent.CLICK, onLuRu);
			jiaofei.addEventListener(MouseEvent.CLICK, onJiaoFei);
			fapiao.addEventListener(MouseEvent.CLICK, onFaPiao);
			shouju.addEventListener(MouseEvent.CLICK, onShouJu);
			xiugai.addEventListener(MouseEvent.CLICK, onXiuGai);
			comb1.visible = false;
		}
		
		private function addEventFrame2():void
		{
			radioG = new RadioButtonGroup("radio");
			radioG.addRadioButton(r1);
			radioG.addRadioButton(r2);
			radioG.addRadioButton(r3);
			
			chaxun.addEventListener(MouseEvent.CLICK, onChaXun);
			weiyue.addEventListener(MouseEvent.CLICK, onWeiYue);
			luru.addEventListener(MouseEvent.CLICK, onLuRu);
			jiaofei.addEventListener(MouseEvent.CLICK, onJiaoFei);
			fapiao.addEventListener(MouseEvent.CLICK, onFaPiao);
			shouju.addEventListener(MouseEvent.CLICK, onShouJu);
			xiugai.addEventListener(MouseEvent.CLICK, onXiuGai);
			comb1.addEventListener(Event.CHANGE, onChange);
		}
		
		private function removeEventFrame1():void
		{
			chaxun.removeEventListener(MouseEvent.CLICK, onChaXun);
			weiyue.removeEventListener(MouseEvent.CLICK, onWeiYue);
			luru.removeEventListener(MouseEvent.CLICK, onLuRu);
			jiaofei.removeEventListener(MouseEvent.CLICK, onJiaoFei);
			fapiao.removeEventListener(MouseEvent.CLICK, onFaPiao);
			shouju.removeEventListener(MouseEvent.CLICK, onShouJu);
			xiugai.removeEventListener(MouseEvent.CLICK, onXiuGai);
		}
		
		private function removeEventFrame2():void
		{
			chaxun.removeEventListener(MouseEvent.CLICK, onChaXun);
			weiyue.removeEventListener(MouseEvent.CLICK, onWeiYue);
			luru.removeEventListener(MouseEvent.CLICK, onLuRu);
			jiaofei.removeEventListener(MouseEvent.CLICK, onJiaoFei);
			fapiao.removeEventListener(MouseEvent.CLICK, onFaPiao);
			shouju.removeEventListener(MouseEvent.CLICK, onShouJu);
			xiugai.removeEventListener(MouseEvent.CLICK, onXiuGai);
			comb1.removeEventListener(Event.CHANGE, onChange);
		}
		
		private function onChange(e:Event):void
		{
			if(comb1.selectedLabel == "转账进账单")
			{
				chongyushou.visible = true;
				chongyushou.Close.addEventListener(MouseEvent.CLICK, onClick);
				chongyushou.Close2.addEventListener(MouseEvent.CLICK, onClick);
				chongyushou.save.addEventListener(MouseEvent.CLICK, onSave);
				var d:Date = new Date();
				chongyushou.time1.text = d.fullYear + "-" + (d.month + 1) + "-" + d.date + "  " + d.hours + ":" + d.minutes + ":" + d.seconds;
				chongyushou.time2.text = d.fullYear + "-" + (d.month + 1) + "-" + d.date;
			}
		}
		private var score1:int = 0;
		private function onSave(e:MouseEvent):void
		{
			score1 = 0;
			for(var i:int = 1;i< 5;i++)
			{
				if(chongyushou["txt" + i].text == ExamThreeData.dataArr[i - 1])
				{
					score1 ++;
				}
			}
			for(var i:int = 1;i< 3;i++)
			{
				if(chongyushou["comb" + i].selectedLabel == ExamThreeData.dataArr2[i - 1])
				{
					score1 ++;
				}
			}
		}
		
		private var isChaXun:Boolean = false;
		private function onChaXun(e:MouseEvent):void
		{
			if(isChaXun)
				return;
			if(txt1.text == "")
			{
				this.dispatchEvent(new ProEvent(ProEvent.SEND_NOTICE, {str:getStr()}));
			}
			else
			{
				if(currentFrame != 2)
				{
					var t:String = txt1.text;
					removeEventFrame1();
					gotoAndStop(2);
					addEventFrame2();
					txt1.text = t;
				}
				isChaXun = true;
				yushou.gotoAndStop(2);
			}
		}
		
		private function onWeiYue(e:MouseEvent):void
		{
			if(txt1.text == "")
			{
				this.dispatchEvent(new ProEvent(ProEvent.SEND_NOTICE, {str:getStr()}));
			}
			else
			{
				weiyuejin.visible = true;
				weiyuejin.Close.addEventListener(MouseEvent.CLICK, onClick);
			}
		}
		
		private function onLuRu(e:MouseEvent):void
		{
			lurudianhua.visible = true;
			lurudianhua.Close.addEventListener(MouseEvent.CLICK, onClick);
			lurudianhua.Close2.addEventListener(MouseEvent.CLICK, onClick);
		}
		private var isJiaoFei:Boolean = false;
		private function onJiaoFei(e:MouseEvent):void
		{
			if(isJiaoFei) return;
			if(!isChaXun)
			{
				this.dispatchEvent(new ProEvent(ProEvent.SEND_NOTICE, {str:"请查询后再进行此操作！"}));
			}
			else
			{
				isJiaoFei = true;
				fapiaodayin.visible = true;
				fapiaodayin.Close.addEventListener(MouseEvent.CLICK, onClick);
				fapiaodayin.Close2.addEventListener(MouseEvent.CLICK, onClick);
			}
		}
		
		private function onChongZhang(e:MouseEvent):void
		{
			if(chongyushou.needMoney.text != "")
			{
				chongyushou.visible = false;
				
				fapiaodayin.visible = true;
				fapiaodayin.Close.addEventListener(MouseEvent.CLICK, onClick);
				fapiaodayin.Close2.addEventListener(MouseEvent.CLICK, onClick);
			}
		}
		
		private function onFaPiao(e:MouseEvent):void
		{
			if(!isJiaoFei)
			{
				this.dispatchEvent(new ProEvent(ProEvent.SEND_NOTICE, {str:"请先交费后再进行此操作！"}));
			}
			else
			{
				fapiaodayin.visible = true;
				fapiaodayin.Close.addEventListener(MouseEvent.CLICK, onClick);
				fapiaodayin.Close2.addEventListener(MouseEvent.CLICK, onClick);
			}
		}
		
		private function onShouJu(e:MouseEvent):void
		{
			if(!isJiaoFei)
			{
				this.dispatchEvent(new ProEvent(ProEvent.SEND_NOTICE, {str:"请先交费后再进行此操作！"}));
			}
			else
			{
				this.dispatchEvent(new ProEvent(ProEvent.SEND_NOTICE, {str:"本次收费没有收据需要打印！"}));
			}
		}
		
		private function onXiuGai(e:MouseEvent):void
		{
			xiugaipiaoju.visible = true;
			xiugaipiaoju.Close.addEventListener(MouseEvent.CLICK, onClick);
		}
		
		private function onClick(e:MouseEvent):void
		{
			var dis:DisplayObject = e.currentTarget as DisplayObject;
			dis.removeEventListener(MouseEvent.CLICK,onClick);
			dis.parent.visible = false;
		}
		
		public function getScroe():Object
		{
			var scroe:int = 0;
			if(txt1.text != "") scroe ++;
			if(isChaXun) scroe++;
			if(isJiaoFei) scroe ++;
			scroe += score1;
			//			this.dispatchEvent(new ProEvent(ProEvent.SEND_SCORE, {id:1, score:scroe}));
			trace("id:3, scroe:" + scroe);
			return {id:3, scroe:scroe};
		}
		
		private function getStr():String
		{
			var str:String = "";
			trace(radioG.selectedData);
			trace(radioG.selection);
			switch(int(radioG.selectedData))
			{
				case 1:
				case 2:
					str = "请输入客户编号再进行此操作！";
					break;
				case 3:
					str = "请输入银行账号再进行此操作！";
					break;
			}
			return str;
		}
	}
}